package free.play.validation;

import org.springframework.validation.BindingResult;

import java.util.List;
import java.util.stream.Collectors;

public class BindingResultUtils {

  public static List<String> toErrorCodes(BindingResult bindingResult) {

    return bindingResult.getFieldErrors().stream()
        .map(error -> error.getField() + "." + error.getCode()).collect(Collectors.toList());
  }

}
